<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl"/>

    <script>
        $(function () {
            //查看文章
            $(".showContentBtn").click(function () {
                var id = $(this).data("id");



                //发送异步请求 修改游记状态
               $.get("/travel/selectContentById.do",{id:id},function (data) {
                    //返回的数据填到模态框中
                   console.log(data);
                   $("#showContentModal .modal-body").html(data.content);
                   //展现模态框
                   $("#showContentModal").modal("show");


                });
            });


            //发布
            $(".changeStateBtn").click(function () {
                var id = $(this).data("id");
                var state = $(this).data("state");
                var authorid = $(this).data("authorid");
                //发送异步请求 修改游记状态
                $.get("/travel/changeState.do",{id:id,state:state},function (data) {
                    reload();


                });

                //发送异步请求 创建一条系统消息了
                $.post("messages/systemMessage",{
                    "user.id":authorid,
                    "travel.id":id,
                    "content":"亲,你的游记已经审核通过了!"
                },function (data) {

                });


            });



        });
    </script>


</head>
<body>

<div class="container " style="margin-top: 20px">
   <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#assign currentMenu="travel"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待审核游记列表</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travel/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label>状态:</label>
                    <select id="selectState" class="form-control" name="state">
                        <option value="1">待审核</option>
                        <option value="-1">已拒绝</option>
                    </select>
                    <#--回显-->
                    <script>
                        $("#selectState").val(${(qo.state)!});
                    </script>
                </div>
                <button id="btn_query" class="btn btn-primary">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
            </form>
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>地点</th>
                    <th>作者</th>
                    <th>状态</th>
                    <th></th>
                </tr>
                </thead>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index+1}</td>
                        <td>${entity.title}</td>
                        <td><img src="${entity.coverUrl}" style="width: 30px"/></td>
                        <td>${(entity.place.name)!}</td>
                        <td>${(entity.author.nickName)!}</td>
                        <td>${entity.stateName}</td>
                        <td>
                            <a class="btn btn-success btn-xs btn-input changeStateBtn" data-authorid='${entity.id}' data-id='${entity.id}' data-state="2">
                                <span class="glyphicon glyphicon-ok"></span>发布
                            </a>
                        </td>
                        <td>
                            <a class="btn btn-danger btn-xs btn-input changeStateBtn" data-id='${entity.id}' data-state="-1">
                                <span class="glyphicon glyphicon-ban-circle"></span>拒绝
                            </a>
                        </td>
                        <td>
                            <a class="btn btn-info btn-xs btn-input showContentBtn" data-id='${entity.id}'>
                                <span class="glyphicon glyphicon-zoom-in"></span>查看文章
                            </a>
                        </td>

                    </tr>
                </#list>
            </table>
           <#include "../common/page.ftl"/>
        </div>
    </div>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="showContentModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">充值</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">

            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

</body>
<style>
    #showContentModal img{
        width: 100%;
    }
</style>
</html>